package com.guan.poi.core;

import com.guan.poi.enums.ListAlign;
import com.guan.poi.core.face.Area;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * Excel定义
 */
@SuppressWarnings("rawtypes")
@EqualsAndHashCode(callSuper = true)
@Data
public class Align extends Node implements Area {
	private ListAlign align;

	/**
	 * @param align 排列方式,水平或上下
	 */
	public Align(ListAlign align) {
		this.align = align;
	}

	private List<Area> areas = new ArrayList<>();

	protected <T extends PoiTable> T addTable(T table) {
		table.parent(this);
		areas.add(table);
		return table;
	}

	protected PoiRow addRow(String... values) {
		return addRow(new PoiRow(1, values));
	}

	protected PoiRow addRow(PoiRow row) {
		row.parent(this);
		areas.add(row);
		return row;
	}

	public Split addSplit(Integer split) {
		return addSplit(new Split(split));
	}

	public Split addSplit(Split split) {
		split.parent(this);
		areas.add(split);
		return split;
	}

	protected Align addAlign(Align align) {
		align.parent(this);
		areas.add(align);
		return align;
	}
}
